package co.gov.medellin.ssti.sub.paoyer.administration.util;

import javax.naming.Context;
import javax.rmi.PortableRemoteObject;

import co.gov.medellin.ssti.sub.paoyer.administration.AdministrationFacade;
import co.gov.medellin.ssti.sub.paoyer.administration.AdministrationFacadeHome;
import co.gov.medellin.ssti.sub.paoyer.common.ServiceLocator;

public class AdministrationServiceLocator extends ServiceLocator {
	public AdministrationServiceLocator() {
	}

	/**
	 * Obtiene una referencia a la interfaz remota del facade del modulo de
	 * administracion
	 * 
	 */
	public AdministrationFacade getAdministrationFacade() {

		AdministrationFacadeHome adminFacadeHome = null;
		Context context = null;
		try {
			context = getIASInitialContext();
			// Obtenemos la referencia a la interfaz home

			// adminFacadeHome = ( AdministrationFacadeLocalLocalHome )
			// context.lookup("java:comp/env/ejb/local/AdministrationFacadeLocal");
			// adminFacadeHome = ( AdministrationFacadeLocalLocalHome )
			// PortableRemoteObject.narrow
			// ( context.lookup("AdministrationFacadeLocal"),
			// AdministrationFacadeLocalLocalHome.class);
			adminFacadeHome = (AdministrationFacadeHome) PortableRemoteObject
					.narrow(context.lookup("ejb/AdministrationFacadeLocal"),
							AdministrationFacadeHome.class);
			return adminFacadeHome.create();
		} catch (Exception ex) {
			System.err.println("/******** TDSUB - cwsub");
			ex.printStackTrace();
			System.err.println("TDSUB - cwsub ********/");
			return null;
		}
	}

}